import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login.vue'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            redirect: '/home'
        },
        {
            path: '/login',
            name: 'login',
            component: Login,
            meta: {
                title: '轻教育-登录页面'
            }
        },
        {
            path: '/register',
            name: 'register',
            component: () => import('@/views/Register.vue'),
            meta: {
                title: '轻教育-注册'
            },
        },
        {
            path: '/home',
            name: 'home',
            component: () => import('@/views/Home.vue'),
            meta: {
                title: '轻教育-首页'
            },
            children: [ //  会自动在这两个之间加一个斜杠
                {
                    path: 'course_table',
                    name: 'course_table',
                    component: () => import('@/components/CourseTable.vue'),
                    meta: {
                        title: '首页-课程表'
                    },
                },
                {
                    path: 'mine',
                    name: 'mine',
                    component: () => import('@/components/Mine.vue'),
                    meta: {
                        title: '首页-我的'
                    },
                },
                {
                    path: 'chat',
                    name: 'chat',
                    component: () => import('@/components/Chat.vue'),
                    meta: {
                        title: '首页-聊天界面'
                    },
                }
            ]
        },
    ]
})

export default router
